package com.ruoyi.web.controller.construction.strategy;

import java.util.List;

import com.ruoyi.system.domain.construction.strategy.ConstructionStrategyCase;
import com.ruoyi.system.service.construction.strategy.ConstructionStrategyCaseService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 施工攻略案例说明Controller
 * 
 * @author zhangshaocong
 * @date 2020-12-03
 */
@RestController
@RequestMapping("/construction/case")
public class ConstructionStrategyCaseController extends BaseController
{
    @Autowired
    private ConstructionStrategyCaseService constructionStrategyCaseService;

    /**
     * 查询施工攻略案例说明列表
     */
    @PreAuthorize("@ss.hasPermi('construction:case:list')")
    @GetMapping("/list")
    public TableDataInfo list(ConstructionStrategyCase constructionStrategyCase)
    {
        startPage();
        List<ConstructionStrategyCase> list = constructionStrategyCaseService.selectConstructionStrategyCaseList(constructionStrategyCase);
        return getDataTable(list);
    }

    /**
     * 导出施工攻略案例说明列表
     */
    @PreAuthorize("@ss.hasPermi('construction:case:export')")
    @Log(title = "施工攻略案例说明", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ConstructionStrategyCase constructionStrategyCase)
    {
        List<ConstructionStrategyCase> list = constructionStrategyCaseService.selectConstructionStrategyCaseList(constructionStrategyCase);
        ExcelUtil<ConstructionStrategyCase> util = new ExcelUtil<ConstructionStrategyCase>(ConstructionStrategyCase.class);
        return util.exportExcel(list, "case");
    }

    /**
     * 获取施工攻略案例说明详细信息
     */
    @PreAuthorize("@ss.hasPermi('construction:case:query')")
    @GetMapping(value = "/{strategyCaseId}")
    public AjaxResult getInfo(@PathVariable("strategyCaseId") Long strategyCaseId)
    {
        return AjaxResult.success(constructionStrategyCaseService.selectConstructionStrategyCaseById(strategyCaseId));
    }

    /**
     * 新增施工攻略案例说明
     */
    @PreAuthorize("@ss.hasPermi('construction:case:add')")
    @Log(title = "施工攻略案例说明", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ConstructionStrategyCase constructionStrategyCase)
    {
        return toAjax(constructionStrategyCaseService.insertConstructionStrategyCase(constructionStrategyCase));
    }

    /**
     * 修改施工攻略案例说明
     */
    @PreAuthorize("@ss.hasPermi('construction:case:edit')")
    @Log(title = "施工攻略案例说明", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ConstructionStrategyCase constructionStrategyCase)
    {
        return toAjax(constructionStrategyCaseService.updateConstructionStrategyCase(constructionStrategyCase));
    }

    /**
     * 删除施工攻略案例说明
     */
    @PreAuthorize("@ss.hasPermi('construction:case:remove')")
    @Log(title = "施工攻略案例说明", businessType = BusinessType.DELETE)
	@DeleteMapping("/{strategyCaseIds}")
    public AjaxResult remove(@PathVariable Long[] strategyCaseIds)
    {
        return toAjax(constructionStrategyCaseService.deleteConstructionStrategyCaseByIds(strategyCaseIds));
    }
}
